// Ramsay 2011 IO

// Load original dataset
clear
use "R2011 IO Rep Data.dta"

// REPLICATION
count
summarize
display c(k)
mdesc
tabmiss
codebook ccode
codebook year

// Table 3
// Model 1
tsset ccode year, yearly
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) i.year, robust bw(2)small rf endog(logoilrevpc) first savefirst savefprefix(first)
mdesc normpolity2 logoilrevpc logORDdef2k yr*
codebook year if e(sample)
codebook ccode if e(sample)

// Model 2
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)
mdesc normpolity2 logoilrevpc logORDdef2k loggdppc yr*
codebook year if e(sample)
codebook ccode if e(sample)

// Model 3
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)
mdesc normpolity2 logoilrevpc logORDdef2k loggdppc gdpgrowth year
codebook year if e(sample)
codebook ccode if e(sample)

// Model 4
xi: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth polity68 i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)
mdesc normpolity2 logoilrevpc logORDdef2k loggdppc gdpgrowth polity68 year
codebook year if e(sample)
codebook ccode if e(sample)

// IMPUTATION
clear
use "R2011 IO Imp Data.dta"
summarize
mi import flong, m(imp) id(year ccode) imp(gdpgrowth-logreserv f_brit-logORDdef2k)
mi tsset ccode year, yearly

// Table 3
// Model 1
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) i.year, robust bw(2)small rf endog(logoilrevpc) first savefirst savefprefix(first)

// Model 2
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 3
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

// Model 4
xi: mi estimate, cmdok post: ivreg2 normpolity2 (logoilrevpc=logORDdef2k) loggdppc gdpgrowth polity68 i.year, robust bw(2) small rf endog(logoilrevpc) savefirst first savefprefix(first)

